<template>
  <div class="container">
    <van-button type="primary">主要按钮</van-button>
    <van-button type="success">成功按钮</van-button>
    <van-button type="default">默认按钮</van-button>
    <van-button type="warning">警告按钮</van-button>
    <van-button type="danger">危险按钮</van-button>
    <h1>视频DEMO</h1>
    <h1>ckplayer</h1>
    <div id="video"></div>   用ck这个视屏写
    <h1>xgplayer</h1>
    <div id="mse"></div>
    <h1>dplayer</h1>
    <div id="dplayer"></div>
  </div>
</template>

<script>
// import xgplayer from 'xgplayer'
import DPlayer from 'dplayer'
import HlsJsPlayer from 'xgplayer-hls'
import Hls from 'hls.js'

export default {
  name: 'Home',
  data() {
    return {
      url: 'http://dlhls.cdn.zhanqi.tv/zqlive/22578_yKdJM.m3u8',
      ckplayer: null,
      xgplayer: null,
      DPlayer: null
    }
  },
  mounted() {
    // 挂载完成后进行
    var videoObject = {
      container: '#video', //容器的ID或className
      plug: 'hls.js',
      // live: true,
      video: this.url
    }
    // 定义一个对象
    this.ckplayer = new window.ckplayer(videoObject)
    this.xgplayer = new HlsJsPlayer({
      id: 'mse',
      url: this.url
    })
    this.DPlayer = new DPlayer({
      container: document.getElementById('dplayer'),
      autoplay: true,
      video: {
        url: this.url,
        type: 'customHls',
        customType: {
          customHls: function (video) {
            const hls = new Hls()
            hls.loadSource(video.src)
            hls.attachMedia(video)
          }
        }
      }
    })
  }
}
</script>

<style lang="scss" scoped>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
#video,
#mse,
#dplayer {
  width: 600px;
  height: 400px;
  margin: 0px auto;
}
.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  // background: lightblue;
}
</style>